﻿//Created by Action Script Viewer - http://www.buraks.com/asv
package Modules.guide {
    import Engine.Classes.*;
    import Engine.Managers.*;
    import Engine.Helpers.*;
    import flash.utils.*;
    import Classes.*;
    import Display.*;
    import Display.MarketUI.*;
    import GameMode.*;
    import Mechanics.ClientDisplayMechanics.*;
    import Modules.guide.actions.*;
    import Display.peddlerUI.*;

    public class GuideCallbackHelper {

        protected var m_deliveryBusiness:Business = null;

        public function registerHandlers(_arg1:Guide):void{
            _arg1.registerCallback("advanceToCatalogItem", this.advanceToCatalogItem);
            _arg1.registerCallback("isCatalogOpen", this.isCatalogOpen);
            _arg1.registerCallback("isCatalogClosed", this.isCatalogClosed);
            _arg1.registerCallback("closeCatalog", this.closeCatalog);
            _arg1.registerCallback("openCatalog", this.openCatalog);
            _arg1.registerCallback("isPlacingResource", this.isPlacingResource);
            _arg1.registerCallback("isPlayMode", this.isPlayMode);
            _arg1.registerCallback("createRandomNpcs", this.createRandomNpcs);
            _arg1.registerCallback("noMoreDoobers", this.noMoreDoobers);
            _arg1.registerCallback("isCatalogTabOpen", this.isCatalogTabOpen);
            _arg1.registerCallback("spawnedDoobers", this.spawnedDoobers);
            _arg1.registerCallback("finishedMoveIn", this.finishedMoveIn);
            _arg1.registerCallback("scrollToIsoPosition", this.scrollToIsoPosition);
            _arg1.registerCallback("smoothZoom", this.smoothZoom);
            _arg1.registerCallback("isProgressStarted", this.isProgressStarted);
            _arg1.registerCallback("isActionMenuOpen", this.isActionMenuOpen);
            _arg1.registerCallback("isInventoryOpen", this.isInventoryOpen);
            _arg1.registerCallback("isVisitingFriend", this.isVisitingFriend);
            _arg1.registerCallback("isFranchiseMenuOpen", this.isFranchiseMenuOpen);
            _arg1.registerCallback("isModalDialogClosed", this.isModalDialogClosed);
            _arg1.registerCallback("isWorldLoaded", this.isWorldLoaded);
            _arg1.registerCallback("isDonePanning", this.isDonePanning);
            _arg1.registerCallback("advanceNotifyGuideMechanic", NotifyGuideMechanic.onGuideComplete);
            _arg1.registerCallback("hasSelectPeddler", this.hasSelectPeddler);
            _arg1.registerCallback("hasOpenPeddlerBar", this.hasOpenPeddlerBar);
            _arg1.registerObject("bottomhud", Global.ui.bottomUI);
            _arg1.registerCallback("isZoomOut", this.isZoomOut);
            _arg1.registerCallback("trackCounter", this.trackCounter);
        }
        public function isModalDialogClosed(_arg1:XMLList):Boolean{
            if (UI.isModalDialogOpen){
                return (false);
            };
            return (true);
        }
        public function isFranchiseMenuOpen(_arg1:XMLList):Boolean{
            if (!Global.ui.franchiseMenu){
                return (false);
            };
            return (Global.ui.franchiseMenu.visible);
        }
        public function isVisitingFriend(_arg1:XMLList):Boolean{
            if (!(Global.world.getTopGameMode() is GMVisit)){
                return (false);
            };
            var _local2:String = _arg1.@friendId;
            if (Global.getVisiting() != _local2){
                return (false);
            };
            return (true);
        }
        public function isActionMenuOpen(_arg1:XMLList):Boolean{
            return (Global.ui.isActionMenuOpen);
        }
        public function isInventoryOpen(_arg1:XMLList):Boolean{
            if (!Global.ui.inventoryView){
                return (false);
            };
            return (Global.ui.inventoryView.isShown);
        }
        public function advanceToCatalogItem(_arg1:XMLList):Boolean{
            var _local2:String = String(_arg1.@item);
            var _local3:Item = Global.gameSettings.getItemByName(_local2);
            var _local4:String = _local3.type;
            var _local5:Catalog = UI.m_catalog;
            if (_local5){
                _local5.asset.switchType(_local4);
            } else {
                _local5 = UI.displayCatalog(_local4);
            };
            _local5.asset.goToItem(_local2);
            return (true);
        }
        public function scrollToIsoPosition(_arg1:XMLList):Boolean{
            var _local6:Number;
            var _local2:int = int(_arg1.@x);
            var _local3:int = int(_arg1.@y);
            var _local4:String = _arg1.@instant;
            var _local5:Boolean;
            if (_local4 == "false"){
                _local5 = false;
            } else {
                if (int(_local4) == 0){
                    _local5 = false;
                };
            };
            if (_local5){
                (GlobalEngine.viewport as IsoViewport).centerOnTilePos(_local2, _local3);
            } else {
                _local6 = Number(_arg1.@time);
                if (_local6 == 0){
                    _local6 = 1;
                };
                Global.world.centerOnIsoPosition(new Vector3(_local2, _local3), _local6);
            };
            return (true);
        }
        public function smoothZoom(_arg1:XMLList):Boolean{
            var _local2:int = int(_arg1.@start);
            var _local3:int = int(_arg1.@end);
            var _local4:Number = Number(_arg1.@time);
            var _local5 = (Boolean(_arg1.@instant) == true);
            Global.world.zoom(_local2, _local3, _local4);
            return (true);
        }
        public function isCatalogTabOpen(_arg1:XMLList):Boolean{
            var _local2:String = _arg1.@type;
            var _local3:Catalog = UI.m_catalog;
            if (((_local3) && ((_local3.type == _local2)))){
                return (true);
            };
            return (false);
        }
        public function spawnedDoobers(_arg1:XMLList):Boolean{
            return ((((Global.world.dooberManager.getDooberCount() > 0)) && (Global.world.dooberManager.areDoobersLanded())));
        }
        public function noMoreDoobers(_arg1:XMLList):Boolean{
            return ((Global.world.dooberManager.getDooberCount() <= 0));
        }
        public function finishedMoveIn(_arg1:XMLList):Boolean{
            var _local3:Residence;
            var _local2:Array = Global.world.getObjectsByClass(Residence);
            for each (_local3 in _local2) {
                if (_local3.isMovingIn){
                    return (false);
                };
            };
            return ((_local2.length > 0));
        }
        public function createRandomNpcs(_arg1:XMLList):Boolean{
            var _local2:int = int(_arg1.@count);
            Global.world.citySim.npcManager.createBusinessPeepWalkers(_local2);
            return (true);
        }
        public function isCatalogOpen(_arg1:XMLList):Boolean{
            return (((((((!((UI.m_catalog == null))) && (!((UI.m_catalog.asset == null))))) && (UI.m_catalog.asset.isInitialized))) && (UI.m_catalog.isShown)));
        }
        public function isCatalogClosed(_arg1:XMLList):Boolean{
            return ((((UI.m_catalog == null)) || (!(UI.m_catalog.isShown))));
        }
        public function openCatalog(_arg1:XMLList):Boolean{
            var _local2:String;
            if (this.isCatalogClosed(_arg1)){
                if (_arg1.@tabName){
                    _local2 = ((_arg1.@itemName.toString())!="") ? _arg1.@itemName : null;
                    UI.displayCatalog(_arg1.@tabName, _local2);
                };
            };
            return (true);
        }
        public function closeCatalog(_arg1:XMLList):Boolean{
            if (UI.m_catalog != null){
                UI.m_catalog.close();
                UI.m_catalog = null;
            };
            return (true);
        }
        public function isPlacingResource(_arg1:XMLList):Boolean{
            var _local2:GMPlaceMapResource = (Global.world.getTopGameMode() as GMPlaceMapResource);
            var _local3:String = String(_arg1.@item);
            return (((!((_local2 == null))) && ((((_local3 == "")) || ((_local3 == _local2.itemName))))));
        }
        public function hasOpenPeddlerBar(_arg1:XMLList):Boolean{
            return (PeddlerBar.getInstance().visible);
        }
        public function isPlayMode(_arg1:XMLList):Boolean{
            return ((Global.world.getTopGameMode() is GMPlay));
        }
        public function isProgressStarted(_arg1:XMLList):Boolean{
            var def:* = null;
            var className:* = null;
            var obj:* = null;
            var xmldef:* = _arg1;
            try {
                def = getDefinitionByName(("Classes." + xmldef.@className));
                className = (def as Class);
                for each (obj in Global.world.getObjectsByClass(className)) {
                    if (obj.actionBar){
                        return (true);
                    };
                };
            } catch(e:Error) {
            };
            return (false);
        }
        public function hasSelectPeddler(_arg1:XMLList):Boolean{
            return (((Global.peddlerManager) && (!((Global.peddlerManager.selectPeddler == null)))));
        }
        public function isWorldLoaded(_arg1:XMLList):Boolean{
            return (!(Global.isTransitioningWorld));
        }
        public function isDonePanning(_arg1:XMLList):Boolean{
            return (!(GAPanMap.isPanningMap));
        }
        public function trackCounter(_arg1:XMLList):Boolean{
            if (!_arg1.@counter){
                if (Config.DEBUG_MODE){
                    throw (new Error("Invalid Guide Stat: Must specify a counter"));
                };
                return (true);
            };
            var _local2:String = _arg1.@counter;
            var _local3:String = _arg1.@kingdom;
            var _local4:String = _arg1.@phylum;
            var _local5:String = _arg1.@zclass;
            var _local6:String = _arg1.@family;
            var _local7:String = _arg1.@genus;
            var _local8:int = (_arg1.hasOwnProperty("@value")) ? _arg1.@value : 1;
            StatsManager.count(_local2, _local3, _local4, _local5, _local6, _local7, _local8);
            return (true);
        }
        public function isZoomOut(_arg1:XMLList):Boolean{
            SettingsMenu.handleFullscreenToggle();
            return (true);
        }

    }
}//package Modules.guide 
